Skip to content

fix: terminal drawer fails to load on ultrawide displays#2342

Closed
BlueManCZ wants to merge 3 commits into
pingdotgg:mainfrom
BlueManCZ:fix/terminal-ultrawide
Closed

fix: terminal drawer fails to load on ultrawide displays#2342
BlueManCZ wants to merge 3 commits into
pingdotgg:mainfrom
BlueManCZ:fix/terminal-ultrawide

Conversation

@BlueManCZ
Copy link
Copy Markdown

@BlueManCZ BlueManCZ commented Apr 25, 2026

Summary

  • Schema bounds. cols/rows were capped at 400/200, but xterm's FitAddon produces ~411 cols on a 3440x1440 ultrawide. The decode rejected the terminal.open/terminal.resize call client-side and the drawer showed Expected a value less than or equal to 400, got 411 at ["cols"]. Raised to 1000/500 — covers ultrawide / 4K / 8K at small font sizes while staying bounded.
  • Bun PTY defects. With the schema fix in place, the next failure surfaced as the generic Failed to open terminal fallback because BunPTY used Effect.sync, turning any synchronous Bun.spawn throw into an untyped defect. Effect's runPromise rejects with raw Cause.die payloads (verified in isolation), so on the client err instanceof Error returns false and the underlying message is lost. Switched to Effect.try to mirror NodePTY, mapping spawn failures to typed PtySpawnError.
  • Error-message helper. Added extractErrorMessage(error, fallback) that handles Error, objects with a message string, _tag-discriminated RPC payloads, and string rejections, falling back only when nothing meaningful is present. Used in the terminal drawer's open/write catch handlers; the previous err instanceof Error ? err.message : fallback pattern silently swallowed non-Error rejections.

Test plan

  • On a 3440x1440 ultrawide, open the terminal drawer — the terminal loads (no Expected a value less than or equal to 400 error).
  • On a regular display (e.g. 1920x1080), the terminal still loads normally.
  • Force a PTY spawn failure (e.g. point shell resolver at a non-existent binary) — the drawer shows a meaningful error message instead of Failed to open terminal.
  • bun run test passes (added 2 schema-bound tests in terminal.test.ts, 11 helper tests in errorMessage.test.ts).
  • bun fmt, bun lint, bun typecheck clean.

🤖 Generated with Claude Code


Note

Medium Risk
Changes terminal size validation limits and alters Bun PTY spawn error handling, which can affect terminal session creation and resizing across clients. Risk is moderate because failures will now propagate as typed errors and larger dimensions may impact performance/memory in extreme cases.

Overview
Fixes terminal drawer failures on large/ultrawide displays by increasing contract validation bounds for terminal cols/rows (to 1000/500) and adding tests for the new maxima.

Improves terminal error surfacing: Bun’s PTY adapter now wraps Bun.spawn in Effect.try and maps failures to PtySpawnError (instead of dying via Effect.sync), and the web terminal drawer uses a new extractErrorMessage helper to display meaningful messages for non-Error rejections (including _tag-shaped RPC errors) when open/write fail.

Reviewed by Cursor Bugbot for commit ab83fa0. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix terminal drawer failing to load on ultrawide displays by raising max terminal dimensions

  • Increases the accepted terminal size limits in terminal.ts: cols from 400→1000 and rows from 200→500, fixing validation rejection on ultrawide displays.
  • Adds extractErrorMessage utility that normalizes unknown errors to a human-readable string, with fallback support and safe handling of circular references.
  • Uses extractErrorMessage in ThreadTerminalDrawer for both the write and open failure paths.
  • Wraps Bun.spawn in Effect.try in BunPTY.ts so spawn failures surface as typed PtySpawnError instead of a generic thrown error.
  • Behavioral Change: terminals with cols 401–1000 or rows 201–500 are now accepted rather than rejected.

Macroscope summarized ab83fa0.

BlueManCZ and others added 3 commits April 25, 2026 08:49
The previous ceiling (400 cols / 200 rows) was hit by xterm's FitAddon
on a 3440x1440 ultrawide (~411 cols at default density), causing the
schema decode to reject the open/resize call before it reached the
server. Raise to 1000 / 500 to comfortably cover ultrawide / 4K / 8K
at small font sizes while still bounded enough to defend the PTY from
malicious client input.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The Bun PTY adapter used Effect.sync, so any synchronous throw from
Bun.spawn became an unhandled defect that bypassed the typed error
union and reached the RPC client as a non-Error rejection (Effect's
runPromise rejects with raw Cause.die payloads). Mirror NodePTY's
Effect.try pattern so spawn failures surface as typed PtySpawnError.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The instanceof Error ? err.message : fallback pattern silently drops
non-Error rejections (e.g. RPC defects, plain objects with _tag), so
the user sees a generic fallback instead of the underlying detail.
Extract a shared extractErrorMessage helper that handles Error,
objects with a message string, _tag-discriminated payloads, and
string rejections, falling back only when nothing else is meaningful.

Use the helper in the terminal drawer's open/write catch handlers.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b983eda3-e0b9-4d23-8faa-5354e17af110

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Apr 25, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Apr 25, 2026

Approvability

Verdict: Approved

Straightforward bug fix that raises terminal dimension limits to support ultrawide displays, with defensive error handling improvements and a well-tested utility extraction. Low-risk, backwards-compatible changes.

You can customize Macroscope's approvability policy. Learn more.

@BlueManCZ
Copy link
Copy Markdown
Author

Fixed in #2411

@BlueManCZ BlueManCZ closed this May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant